package cn.kicsy.www.anonymous_bbs.config;

import cn.kicsy.www.anonymous_bbs.interceptor.AutoBanInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * Web配置类
 * 用于注册拦截器
 */
@Configuration
public class WebConfig implements WebMvcConfigurer {
    
    @Autowired
    private AutoBanInterceptor autoBanInterceptor;
    
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        // 注册自动封禁IP拦截器
        registry.addInterceptor(autoBanInterceptor)
                .addPathPatterns("/**")  // 拦截所有路径
                .excludePathPatterns("/error", "/static/**", "/css/**", "/js/**", "/images/**");  // 排除静态资源路径
    }
}